﻿using MediatR;
using SlaughterItem.Common.Domains.RKWeigh;
using SlaughterItem.Common.Dtos;
using SlaughterItem.Common.Infrastructures.Interfaces;
using SlaughterItem.Enum;

namespace GetSlaughterItem.API.Application.Commands.Week02.SegmentationStatement_
{
    public class SegmentationStatementHandler : IRequestHandler<SegmentationStatementCommand, Result>
    {
        public SegmentationStatementHandler(IBaseRepositoryGet<RKWeighData> rKWeighDataRepositoryGet)
        {
            RKWeighDataRepositoryGet = rKWeighDataRepositoryGet;
        }

        public IBaseRepositoryGet<RKWeighData> RKWeighDataRepositoryGet { get; set; }
        public async Task<Result> Handle(SegmentationStatementCommand request, CancellationToken cancellationToken)
        {
            var result= new Result() { Code=(int)CommonErrorCode.Search};
            var list = RKWeighDataRepositoryGet.GetAll().Where(x => x.IsWeigh == false).ToList();
            result.Data = list;
            result.Code = (int)CommonErrorCode.Success;
            return result;  
        }
    }
}
